/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package YottaTron;

import java.util.logging.Level;
import java.util.logging.Logger;


public class YotTimer extends Thread{

    int timeout;
    boolean elapsed;
    private TickEvent tickEventObject;

    public YotTimer(TickEvent tickEventObject, int timeout){
        this.tickEventObject = tickEventObject;
        this.timeout = timeout;
        elapsed = false;
        this.start();
        System.out.println("");
    }

    public void reset(){
        elapsed = false;
    }

    @Override
    public void run(){
        while(true){
            try {
                sleep(timeout);
            } catch (InterruptedException ex) {
                Logger.getLogger(YotTimer.class.getName()).log(Level.SEVERE, null, ex);
            }
            elapsed = true;
               tickEventObject.tickEvent();
            //System.out.println("Timeout");
        }
    }

}
